<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The SolrDocument class</title>
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-base.css" />
<link media="all" rel="stylesheet" type="text/css" href="styles/03e73060321a0a848018724a6c83de7f-theme-medium.css" />

 </head>
 <body class="docs"><div class="navbar navbar-fixed-top">
  <div class="navbar-inner clearfix">
    <ul class="nav" style="width: 100%">
      <li style="float: left;"><a href="solrinputdocument.toarray.html">« SolrInputDocument::toArray</a></li>
      <li style="float: right;"><a href="solrdocument.addfield.html">SolrDocument::addField »</a></li>
    </ul>
  </div>
</div>
<div id="breadcrumbs" class="clearfix">
  <ul class="breadcrumbs-container">
    <li><a href="index.html">PHP Manual</a></li>
    <li><a href="book.solr.html">Solr</a></li>
    <li>The SolrDocument class</li>
  </ul>
</div>
<div id="layout">
  <div id="layout-content"><div id="class.solrdocument" class="reference">

 <h1 class="title">The SolrDocument class</h1>
 

 <div class="partintro"><p class="verinfo">(PECL solr &gt;= 0.9.2)</p>


  <div class="section" id="solrdocument.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    Represents a Solr document retrieved from a query response.
   </p>
  </div>


  <div class="section" id="solrdocument.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass"></div>


    <div class="classsynopsisinfo">
     <span class="ooclass">
      <span class="modifier">final</span>
      <span class="modifier">class</span> <strong class="classname">SolrDocument</strong>
     </span>
     
     <span class="oointerface"><span class="modifier">implements</span> 
       <a href="class.arrayaccess.html" class="interfacename">ArrayAccess</a></span><span class="oointerface">,  <a href="class.iterator.html" class="interfacename">Iterator</a></span><span class="oointerface">,  <a href="class.serializable.html" class="interfacename">Serializable</a></span> {</div>

    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 常量 */</div>
    <div class="fieldsynopsis">
     <span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.solrdocument.html#solrdocument.constants.sort-default"><var class="varname">SORT_DEFAULT</var></a></var><span class="initializer"> = 1</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.solrdocument.html#solrdocument.constants.sort-asc"><var class="varname">SORT_ASC</var></a></var><span class="initializer"> = 1</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.solrdocument.html#solrdocument.constants.sort-desc"><var class="varname">SORT_DESC</var></a></var><span class="initializer"> = 2</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.solrdocument.html#solrdocument.constants.sort-field-name"><var class="varname">SORT_FIELD_NAME</var></a></var><span class="initializer"> = 1</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.solrdocument.html#solrdocument.constants.sort-field-value-count"><var class="varname">SORT_FIELD_VALUE_COUNT</var></a></var><span class="initializer"> = 2</span>;</div>

    <div class="fieldsynopsis"><span class="modifier">const</span>
     <span class="type">int</span>
      <var class="fieldsynopsis_varname"><a href="class.solrdocument.html#solrdocument.constants.sort-field-boost-value"><var class="varname">SORT_FIELD_BOOST_VALUE</var></a></var><span class="initializer"> = 4</span>;</div>

    
    <div class="classsynopsisinfo classsynopsisinfo_comment">/* 方法 */</div>
    <div class="constructorsynopsis dc-description">
   <span class="modifier">public</span> <span class="methodname"><a href="solrdocument.construct.html" class="methodname">__construct</a></span>()</div>

    <div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.addfield.html" class="methodname">addField</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldValue</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.clear.html" class="methodname">clear</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.clone.html" class="methodname">__clone</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.current.html" class="methodname">current</a></span>(): <span class="type"><a href="class.solrdocumentfield.html" class="type SolrDocumentField">SolrDocumentField</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.deletefield.html" class="methodname">deleteField</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.fieldexists.html" class="methodname">fieldExists</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.get.html" class="methodname">__get</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>): <span class="type"><a href="class.solrdocumentfield.html" class="type SolrDocumentField">SolrDocumentField</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.getchilddocuments.html" class="methodname">getChildDocuments</a></span>(): <span class="type">array</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.getchilddocumentscount.html" class="methodname">getChildDocumentsCount</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.getfield.html" class="methodname">getField</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>): <span class="type"><a href="class.solrdocumentfield.html" class="type SolrDocumentField">SolrDocumentField</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.getfieldcount.html" class="methodname">getFieldCount</a></span>(): <span class="type">int</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.getfieldnames.html" class="methodname">getFieldNames</a></span>(): <span class="type">array</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.getinputdocument.html" class="methodname">getInputDocument</a></span>(): <span class="type"><a href="class.solrinputdocument.html" class="type SolrInputDocument">SolrInputDocument</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.haschilddocuments.html" class="methodname">hasChildDocuments</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.isset.html" class="methodname">__isset</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.key.html" class="methodname">key</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.merge.html" class="methodname">merge</a></span>(<span class="methodparam"><span class="type"><a href="class.solrdocument.html" class="type SolrDocument">SolrDocument</a></span> <code class="parameter">$sourceDoc</code></span>, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$overwrite</code><span class="initializer"> = <strong><code>true</code></strong></span></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.next.html" class="methodname">next</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.offsetexists.html" class="methodname">offsetExists</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.offsetget.html" class="methodname">offsetGet</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>): <span class="type"><a href="class.solrdocumentfield.html" class="type SolrDocumentField">SolrDocumentField</a></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.offsetset.html" class="methodname">offsetSet</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldValue</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.offsetunset.html" class="methodname">offsetUnset</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.reset.html" class="methodname">reset</a></span>(): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.rewind.html" class="methodname">rewind</a></span>(): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.serialize.html" class="methodname">serialize</a></span>(): <span class="type">string</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.set.html" class="methodname">__set</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>, <span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldValue</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.sort.html" class="methodname">sort</a></span>(<span class="methodparam"><span class="type">int</span> <code class="parameter">$sortOrderBy</code></span>, <span class="methodparam"><span class="type">int</span> <code class="parameter">$sortDirection</code><span class="initializer"> = SolrDocument::SORT_ASC</span></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.toarray.html" class="methodname">toArray</a></span>(): <span class="type">array</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.unserialize.html" class="methodname">unserialize</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$serialized</code></span>): <span class="type"><span class="type void">void</span></span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.unset.html" class="methodname">__unset</a></span>(<span class="methodparam"><span class="type">string</span> <code class="parameter">$fieldName</code></span>): <span class="type">bool</span></div>
<div class="methodsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.valid.html" class="methodname">valid</a></span>(): <span class="type">bool</span></div>

    <div class="destructorsynopsis dc-description"><span class="modifier">public</span> <span class="methodname"><a href="solrdocument.destruct.html" class="methodname">__destruct</a></span>()</div>

   }</div>


  </div>

  

  <div class="section" id="solrdocument.constants">
   <h2 class="title">预定义常量</h2>
   <dl>

    
     <dt id="solrdocument.constants.sort-default"><strong><code>SolrDocument::SORT_DEFAULT</code></strong></dt>

     <dd>

      <p class="para">Default mode for sorting fields within the document.</p>
     </dd>

    

    
     <dt id="solrdocument.constants.sort-asc"><strong><code>SolrDocument::SORT_ASC</code></strong></dt>

     <dd>

      <p class="para">Sorts the fields in ascending order</p>
     </dd>

    

    
     <dt id="solrdocument.constants.sort-desc"><strong><code>SolrDocument::SORT_DESC</code></strong></dt>

     <dd>

      <p class="para">Sorts the fields in descending order</p>
     </dd>

    

    
     <dt id="solrdocument.constants.sort-field-name"><strong><code>SolrDocument::SORT_FIELD_NAME</code></strong></dt>

     <dd>

      <p class="para">Sorts the fields by field name.</p>
     </dd>

    

    
     <dt id="solrdocument.constants.sort-field-value-count"><strong><code>SolrDocument::SORT_FIELD_VALUE_COUNT</code></strong></dt>

     <dd>

      <p class="para">Sorts the fields by number of values in each field.</p>
     </dd>

    

    
     <dt id="solrdocument.constants.sort-field-boost-value"><strong><code>SolrDocument::SORT_FIELD_BOOST_VALUE</code></strong></dt>

     <dd>

      <p class="para">Sorts the fields by thier boost values.</p>
     </dd>

    

   </dl>

  </div>



 </div>

 








































































































































































































































<h2>目录</h2><ul class="chunklist chunklist_reference"><li><a href="solrdocument.addfield.html">SolrDocument::addField</a> — Adds a field to the document</li><li><a href="solrdocument.clear.html">SolrDocument::clear</a> — Drops all the fields in the document</li><li><a href="solrdocument.clone.html">SolrDocument::__clone</a> — Creates a copy of a SolrDocument object</li><li><a href="solrdocument.construct.html">SolrDocument::__construct</a> — Constructor</li><li><a href="solrdocument.current.html">SolrDocument::current</a> — Retrieves the current field</li><li><a href="solrdocument.deletefield.html">SolrDocument::deleteField</a> — Removes a field from the document</li><li><a href="solrdocument.destruct.html">SolrDocument::__destruct</a> — Destructor</li><li><a href="solrdocument.fieldexists.html">SolrDocument::fieldExists</a> — Checks if a field exists in the document</li><li><a href="solrdocument.get.html">SolrDocument::__get</a> — Access the field as a property</li><li><a href="solrdocument.getchilddocuments.html">SolrDocument::getChildDocuments</a> — Returns an array of child documents (SolrDocument)</li><li><a href="solrdocument.getchilddocumentscount.html">SolrDocument::getChildDocumentsCount</a> — Returns the number of child documents</li><li><a href="solrdocument.getfield.html">SolrDocument::getField</a> — Retrieves a field by name</li><li><a href="solrdocument.getfieldcount.html">SolrDocument::getFieldCount</a> — Returns the number of fields in this document</li><li><a href="solrdocument.getfieldnames.html">SolrDocument::getFieldNames</a> — Returns an array of fields names in the document</li><li><a href="solrdocument.getinputdocument.html">SolrDocument::getInputDocument</a> — Returns a SolrInputDocument equivalent of the object</li><li><a href="solrdocument.haschilddocuments.html">SolrDocument::hasChildDocuments</a> — Checks whether the document has any child documents</li><li><a href="solrdocument.isset.html">SolrDocument::__isset</a> — Checks if a field exists</li><li><a href="solrdocument.key.html">SolrDocument::key</a> — Retrieves the current key</li><li><a href="solrdocument.merge.html">SolrDocument::merge</a> — Merges source to the current SolrDocument</li><li><a href="solrdocument.next.html">SolrDocument::next</a> — Moves the internal pointer to the next field</li><li><a href="solrdocument.offsetexists.html">SolrDocument::offsetExists</a> — Checks if a particular field exists</li><li><a href="solrdocument.offsetget.html">SolrDocument::offsetGet</a> — Retrieves a field</li><li><a href="solrdocument.offsetset.html">SolrDocument::offsetSet</a> — Adds a field to the document</li><li><a href="solrdocument.offsetunset.html">SolrDocument::offsetUnset</a> — Removes a field</li><li><a href="solrdocument.reset.html">SolrDocument::reset</a> — 别名 SolrDocument::clear</li><li><a href="solrdocument.rewind.html">SolrDocument::rewind</a> — Resets the internal pointer to the beginning</li><li><a href="solrdocument.serialize.html">SolrDocument::serialize</a> — Used for custom serialization</li><li><a href="solrdocument.set.html">SolrDocument::__set</a> — Adds another field to the document</li><li><a href="solrdocument.sort.html">SolrDocument::sort</a> — Sorts the fields in the document</li><li><a href="solrdocument.toarray.html">SolrDocument::toArray</a> — Returns an array representation of the document</li><li><a href="solrdocument.unserialize.html">SolrDocument::unserialize</a> — Custom serialization of SolrDocument objects</li><li><a href="solrdocument.unset.html">SolrDocument::__unset</a> — Removes a field from the document</li><li><a href="solrdocument.valid.html">SolrDocument::valid</a> — Checks if the current position internally is still valid</li></ul>
</div>
</div></div></body></html>